﻿@inject IJSRuntime JSRuntime

<a @ref=SlotRef href="@To" class="@ClassName" @onclick="HandleClick" @onclick:preventDefault>@ChildContent</a>

@code {
    ElementReference SlotRef;

    [Parameter]
    public string To { get; set; }

    [Parameter]
    public string ClassName { get; set; }

    [Parameter]
    public RenderFragment ChildContent { get; set; }

    void HandleClick(MouseEventArgs e)
    {
        JSRuntime.InvokeVoidAsync("Blazor.emitNavigateEvent", SlotRef, To);
    }
}
